<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="${codeGenConfig.table.packageVar!}.mapper.${codeGenConfig.table.classVar!}Mapper">
<resultMap id="${codeGenConfig.table.classVar!}Map" type="${codeGenConfig.table.entityPackageVar!}.entity.${codeGenConfig.table.classVar!}">
<#list tableClass.fieldColumns as fieldColumn>
    <!--${fieldColumn.propName!}-->
    <result column="${fieldColumn.columnName!}" property="${fieldColumn.javaProperty!}"/>
</#list>
</resultMap>
    <!--列信息-->
    <sql id="column_list">
        <#list tableClass.fieldColumns as fieldColumn>${fieldColumn.columnName!}<#if fieldColumn_has_next>,</#if></#list>
    </sql>
    <!--动态条件-->
    <sql id="where_filters">
        <where>
        <#list tableClass.fieldColumns as fieldColumn>
            <if test="${fieldColumn.javaProperty!} !=null">
                AND ${fieldColumn.columnName!}=${r"#{"}${fieldColumn.javaProperty!}${r"}"}
            </if>
        </#list>
        </where>
    </sql>

    <select id="selectList" parameterType="map" resultMap="${codeGenConfig.table.classVar!}Map">
        select
        <include refid="column_list"/>
        from ${codeGenConfig.table.tableCode!}
        <include refid="where_filters"/>
        <if test="sortField != null and sortField != ''">
            ORDER BY ${r"${"}sortField${r"}"}
            <if test="sortType != null and sortType != ''">
            ${r"${"}sortType${r"}"}
            </if>
        </if>
    </select>

    <select id="selectRowCount" parameterType="map" resultType="java.lang.Integer">
        select
          count(*)
        from ${codeGenConfig.table.tableCode!}
        <include refid="where_filters"/>
    </select>


</mapper>